View Javadoc

1   
2   
3   package org.opensciencegrid.authz.saml;
4   
5   
6   
7   import org.opensaml.v1_0_1.SAMLSubject;
8   
9   import org.opensaml.v1_0_1.SAMLAction;
10  
11  
12  
13  /***
14  
15   * Utility functions to simplify consistent
16  
17   * processing of SAML objects
18  
19   *
20  
21   * Project: Privilege Project / OpenScienceGrid
22  
23   *
24  
25   * @author     Markus Lorch
26  
27   * @created    January 8, 2005
28  
29   */
30  
31  
32  
33  public class SAMLUtil
34  
35  {
36  
37  
38  
39      /*** Method to compare two SAMLSubjects based on the contents of their
40  
41       *  SAMLNameIdentifier objects alone (Name, NameQualifier, NameFormat)
42  
43       *  returns true if equal, false if the SAMLSubjects differ
44  
45       */
46  
47  
48  
49      public static boolean samlSubjectMatch(SAMLSubject s1, SAMLSubject s2) {
50  
51  
52  
53        if(s1.getName().getName().equals(s2.getName().getName()))
54  
55          if(s1.getName().getNameQualifier().equals(s2.getName().getNameQualifier()))
56  
57             if(s1.getName().getFormat().equals(s2.getName().getFormat()))
58  
59                return true;
60  
61  
62  
63      return false;
64  
65  
66  
67      } // end SAMLSubjectMatch
68  
69  
70  
71      /*** Method to compare two SAMLAction objects, 
72  
73       *  returns true if equal. <br>
74  
75       *  actions are considered equal if they have matching 
76  
77       *  namespaces and matching data fields (string.equals)
78  
79       */
80  
81  
82  
83      public static boolean samlActionMatch(SAMLAction s1, SAMLAction s2) {
84  
85  
86  
87        if(s1.getNamespace().equals(s2.getNamespace()))
88  
89          if(s1.getData().equals(s2.getData()))
90  
91                return true;
92  
93  
94  
95      return false;
96  
97  
98  
99      } // end SAMLActionMatch
100 
101 
102 
103 }
104